package com.lyrcsoft.webflux_02;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

/**
 * 类似GetMapping的定义
 */
@Component
public class WebFluxHandler {
    public Mono<ServerResponse> hello(ServerRequest request) {
        //
        return ServerResponse
                .ok()
                // 文本类型
                .contentType(MediaType.TEXT_PLAIN)
                // 在body里面定义消息
                .body(Mono.just("hello webflux"), String.class);
    }
}
